# coding=utf-8
from __future__ import absolute_import, unicode_literals

import wechatpy

from os.path import join, dirname, abspath
parent_dir = abspath(join(dirname(__file__), '..'))
import sys
sys.path.append(parent_dir)

from ccc import settings


def menu_json(*menus):
    return {
        'button': [{
            'name': menu[0],
            'sub_button': [
                {
                    'type': 'click',
                    'name': item,
                    'key': item
                } for item in menu[1]
            ]
        } for menu in menus]
    }


request_json = menu_json([
    '查询', ['报人', '查人', '名单']
], [
    '加班', ['晚加班', '午加班', '取消加班']
], [
    '请假', ['出差', '事假', '病假', '回家', '销假']
])

# from pprint import pprint
# pprint(request_json)

client = wechatpy.WeChatClient(settings.WEIXIN_APP_ID, settings.WEIXIN_SECRET)
client.menu.create(request_json)